package org.example.musicserver.controller;

import jakarta.annotation.Resource;
import org.example.musicserver.Request.PlayListRequest;
import org.example.musicserver.common.Result;
import org.example.musicserver.service.PlayListService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class PlayListController {
    @Resource
    private PlayListService playListService;

    //返回所有歌单
    @GetMapping("/playList")
    public Result getAllPlayList(@RequestParam(required = false) String query) {
        return Result.success("获取所有歌单成功",playListService.getAllPlayList(query));
    }

    //返回某个歌单
    @GetMapping("/playList/detail")
    public Result getPlayListById(Integer id) {
        return playListService.playListOfId(id);
    }

    @DeleteMapping("/deleteplaylist")
    public Result deletePlayList(@RequestParam Integer id) {
        return playListService.deletePlayList(id);
    }

    //根据列表删除多个歌单
    @DeleteMapping("/deleteallplay")
    public Result deletePlayList(@RequestParam List<Integer> playIds) {
        return playListService.deletePlayLists(playIds);
    }

    @PostMapping("/addPlayList")
    public Result addPlayList(@RequestBody PlayListRequest registryRequest) {
        return playListService.addPlayList(registryRequest);
    }

    @PutMapping("/updatePlayList")
    public Result updatePlayList(@RequestBody PlayListRequest updateRequest) {
        return playListService.updatePlayList(updateRequest);
    }

}
